﻿using System;


namespace FireBus.Contracts
{
	[Serializable]
	public class TypeName : ValueObject<String>
	{
		public TypeName(String name)
		{
			if (String.IsNullOrEmpty(name))
			{
				throw new ArgumentNullException("name");
			}
			Value = name;
		}

		public static implicit operator String(TypeName name)
		{
			return ToString(name);
		}

		public static String ToString(TypeName name)
		{
			return name == null ? null : name.Value;
		}

		public static implicit operator TypeName(String name)
		{
			return new TypeName(name);
		}

		public static implicit operator TypeName(Type type)
		{
			if (type == null)
			{
				return null;
			}
			return new TypeName(type.AssemblyQualifiedName);
		}
	}
}
